Drought · Climate · Rainfall Anomaly

SPI – Standardized Precipitation Index

SPI is a widely used drought index that quantifies precipitation anomalies over different accumulation periods (e.g. 1-, 3-, 6-month) by comparing current rainfall to a long-term climatology. Negative SPI values indicate dry conditions, while positive values indicate wet conditions.
مؤشر SPI لقياس الجفاف عن طريق مقارنة كميات الأمطار الحالية بمتوسط طويل المدى، بحيث تعبر القيم السالبة عن الجفاف والقيم الموجبة عن فترات رطبة.

1. Scientific Definition

The Standardized Precipitation Index (SPI) transforms a time series of accumulated precipitation into a standardized variable with zero mean and unit variance for a given time scale (1, 3, 6, 12 months, etc.). In the full definition, rainfall is fitted to a probability distribution (often gamma) and then converted to a normal distribution. هنا نستخدم نسخة مبسطة على شكل Z-score.

Simple Z-score Formula (Approximation)

لصيغة مبسّطة على شبكة فضائية (راستر):

SPI = (P − μ) / σ Approximate standardized anomaly

  • P – accumulated precipitation for a given period (e.g. 3-month)
  • μ – long-term mean precipitation for the same period / month
  • σ – long-term standard deviation for that period / month

Typical Interpretation (WMO-like classes)

SPIClass
< −2.0Extreme drought
−2.0 – −1.5Severe drought
−1.5 – −1.0Moderate drought
−1.0 – +1.0Near normal
+1.0 – +1.5Moderately wet
+1.5 – +2.0Very wet
> +2.0Extremely wet

هذه الحدود تُستخدم كثيرًا في دراسات الجفاف. تطبيق دقيق للـ SPI يفضل استخدام توزيع جاما، لكن الصيغة أعلاه تعطي تقريب مقبول لمؤشرات الجفاف الإقليمية.

Main Applications

  • Monitoring meteorological and agricultural drought
  • Comparing dryness/wetness between regions with different climates
  • Supporting water resources and drought early-warning systems
  • تحليل التغير المناخي وتأثيره على نمط الأمطار

2. Data & Sources

Recommended Gridded Products

  • CHIRPS – UCSB/CHG/CHIRPS/Monthly (0.05°) – rainfall 1981–present
  • ERA5-Land – reanalysis precipitation
  • National / regional rain-gauge gridded products if available

Time Scales

  • SPI-1: 1-month accumulated rainfall (short-term anomalies)
  • SPI-3: 3-month accumulation – مهم للزراعة الموسمية
  • SPI-6, SPI-12: medium–long term hydrological drought

Best Practices

  • Choose a suitable baseline period (e.g. 1981–2010).
  • Analyse SPI as a time series for each pixel or basin.
  • Combine SPI with soil moisture / NDVI for impact assessment.

Suggested Palette

[ "#7f1d1d", "#b91c1c", "#fecaca", "#e5e7eb", "#bfdbfe", "#1d4ed8", "#1e3a8a" ]

3. Google Earth Engine Code – SPI-1 (Monthly Z-score, CHIRPS)

// SPI-1 (approx.) using CHIRPS Monthly and simple Z-score
// Dataset: UCSB-CHG/CHIRPS/Monthly
// SPI = (P - mean) / std  for a given month-of-year over a baseline period

var roi = geometry;   // Draw AOI as 'geometry'
Map.centerObject(roi, 5);

// ------------------------
// 1. User parameters
// ------------------------
var targetYear = 2023;      // سنة التحليل
var targetMonth = 7;        // شهر التحليل (1 = Jan, 12 = Dec)

var baselineStart = "1981-01-01";  // فترة الأساس
var baselineEnd   = "2010-12-31";  // يمكن تعديلها حسب الحاجة

// ------------------------
// 2. Load CHIRPS monthly rainfall
// ------------------------
var chirps = ee.ImageCollection("UCSB-CHG/CHIRPS/Monthly")
  .filterBounds(roi);

// Helper to extract month & year
var withDate = chirps.map(function(img){
  var d = ee.Date(img.get("system:time_start"));
  return img
    .set("year", d.get("year"))
    .set("month", d.get("month"));
});

// ------------------------
// 3. Build baseline climatology for the target month
// ------------------------
var baseline = withDate
  .filterDate(baselineStart, baselineEnd)
  .filter(ee.Filter.eq("month", targetMonth));

var climMean = baseline.mean().clip(roi).rename("P_mean");
var climStd  = baseline.reduce(ee.Reducer.stdDev()).clip(roi).rename("P_std");

// ------------------------
// 4. Get target month precipitation (SPI-1)
// ------------------------
var target = withDate
  .filter(ee.Filter.eq("year", targetYear))
  .filter(ee.Filter.eq("month", targetMonth))
  .first()
  .clip(roi)
  .rename("P");

// ------------------------
// 5. Compute SPI as Z-score
//    SPI = (P - μ) / σ
//    NOTE: This is an approximation of SPI using normal statistics.
// ------------------------
var spi = target.expression(
  "(P - M) / S",
  {
    "P": target.select("P"),
    "M": climMean.select("P_mean"),
    "S": climStd.select("P_std")
  }
).rename("SPI_1M");

// ------------------------
// 6. Visualization
// ------------------------
var vis = {
  min: -3,
  max:  3,
  palette: ["#7f1d1d","#b91c1c","#fecaca","#e5e7eb","#bfdbfe","#1d4ed8","#1e3a8a"]
};

Map.addLayer(spi, vis, "SPI-1 (" + targetYear + "-" + targetMonth + ")");

// Optional: mask only drought (SPI <= -1)
var drought = spi.lte(-1).selfMask();
Map.addLayer(
  drought,
  {palette:["#b91c1c"]},
  "Drought (SPI <= -1)",
  false
);

// ------------------------
// 7. Export SPI map
// ------------------------
Export.image.toDrive({
  image: spi,
  description: "SPI1_CHIRPS_" + targetYear + "_" + targetMonth,
  fileNamePrefix: "SPI1_CHIRPS_" + targetYear + "_" + targetMonth,
  region: roi,
  scale: 5000,                 // ~5 km; adjust as needed
  crs: "EPSG:4326",
  maxPixels: 1e13
});